import java.util.ArrayList;
import java.util.List;

public class PictureOfStar {

    public String getOneStar() {
        return "*";
    }

    public String getHorizontalLineWithStar(int starNumber) {
        return getHorizontalLineWith("*", starNumber);
    }

    public String getVerticalLine(int starNumber) {
        String result = "";
        for (int n = 0; n < starNumber; n++) {
            result = result.concat("*\n");
        }
        return result;
    }

    public String getRightTriangle(int lineNumOfTriangle) {
        String result = "";
        for (int n = 1; n < lineNumOfTriangle + 1; n++) {
            String lineWithStar = getHorizontalLineWithStar(n).concat("\n");
            result = result.concat(lineWithStar);
        }
        return result;
    }

    public String getCenteredTriangle(int lineNumOfTriangle) {
        return getCentralTriangleWithSpaceBeforeEachLine(lineNumOfTriangle, 0);
    }

    private String getHorizontalLineWith(String element, int elementNum) {
        String result = "";
        for (int n = 0; n < elementNum; n++) {
            result = result.concat(element);
        }
        return result;
    }

    public String getDiamond(int centralLineNumOfDiamond) {
        int upperTriangleLineNum = centralLineNumOfDiamond;
        int lowerTriangleLineNum = centralLineNumOfDiamond - 1;

        String upperTriangle = getCenteredTriangle(upperTriangleLineNum);
        String lowerTriangle = getReservedCenteredTriangleWithSpaceBeforeEachLine(lowerTriangleLineNum, 1);

        return upperTriangle.concat(lowerTriangle);
    }

    private String getReservedCenteredTriangleWithSpaceBeforeEachLine(int lowerTriangleLineNum, int spaceNumBeforeLine) {
        String result = "";
        for (int n = 0; n < lowerTriangleLineNum; n++) {
            String spaceStringBeforeStar = getHorizontalLineWith(" ", n + spaceNumBeforeLine);
            String starStringAfterSpace = getHorizontalLineWithStar(2 * (lowerTriangleLineNum - n) - 1);

            result = result.concat(spaceStringBeforeStar).concat(starStringAfterSpace).concat("\n");
        }
        return result;
    }

    public String getDiamondWithName(int centralLineNumOfDiamond, String name) {
        int triangleLineNum = centralLineNumOfDiamond - 1;
        String upperTriangle = getCentralTriangleWithSpaceBeforeEachLine(triangleLineNum, 1);
        String lowerTriangle = getReservedCenteredTriangleWithSpaceBeforeEachLine(triangleLineNum, 1);

        return upperTriangle.concat(name).concat("\n").concat(lowerTriangle);
    }

    private String getCentralTriangleWithSpaceBeforeEachLine(int lineNum, int spaceNumberBeforeLine) {
        String result = "";
        for (int n = 0; n < lineNum; n++) {
            String spaceStringBeforeStar = getHorizontalLineWith(" ", lineNum - 1 - n + spaceNumberBeforeLine);
            String starStringAfterSpace = getHorizontalLineWithStar(2 * n + 1);

            result = result.concat(spaceStringBeforeStar).concat(starStringAfterSpace).concat("\n");
        }
        return result;
    }

    public String getFizzBuzzNumbersFrom1To100() {
        String result = "";
        for (int n = 1; n < 101; n++) {
            if (isDivisibleByThreeAndFive(n)) {
                result = result.concat("FizzBuzz\n");
            } else if (isDivisibleByThree(n)) {
                result = result.concat("Fizz\n");
            } else if (isDivisibleByFive(n)) {
                result = result.concat("Buzz\n");
            } else {
                StringBuilder num = new StringBuilder();
                String nToString = num.append("").append(n).toString().concat("\n");
                result = result.concat(nToString);
            }
        }
        return result;
    }

    private boolean isDivisibleByThreeAndFive(int n) {
        return isDivisibleByThree(n) && isDivisibleByFive(n);
    }

    private boolean isDivisibleByFive(int n) {
        return n % 5 == 0;
    }

    private boolean isDivisibleByThree(int n) {
        return n % 3 == 0;
    }

    public List<Integer> getFactorsOf(int num) {
        List<Integer> factors = new ArrayList<Integer>();
        for (int n = 1; n < num + 1; n++) {
            boolean nIsOneFactorOfNum = num % n == 0;
            if (nIsOneFactorOfNum) {
                factors.add(n);
            }
        }
        return factors;
    }
}
